const { DataTypes } = require("sequelize");
const sequelize = require("./index");

const Etymology = sequelize.define(
	"etymology",
	{
		id: {
			type: DataTypes.INTEGER,
			primaryKey: true,
			allowNull: false,
			autoIncrement: true,
		},
		title: {
			type: DataTypes.STRING,
			allowNull: false,
		},
		content: {
			type: DataTypes.TEXT,
			allowNull: false,
		},
		createTime: {
			type: DataTypes.DATE,
			allowNull: false,
		},
		etymologyTypeId: {
			type: DataTypes.INTEGER,
			allowNull: false,
		},
		cover: {
			type: DataTypes.TEXT,
		},
	},
	{
		timestamps: false,
	}
);

Etymology.associate = ({ etymologyType }) => {
	Etymology.belongsTo(etymologyType);
};

module.exports = Etymology;
